package com.baidu.mobstat;

import android.content.Context;
import android.os.Handler;
import android.os.HandlerThread;
import com.baidu.mobstat.a.a;
import com.baidu.mobstat.a.b;
import java.lang.ref.WeakReference;
import org.json.JSONException;
import org.json.JSONObject;

class m
{
  private static HandlerThread a = new HandlerThread("SessionAnalysisThread");
  private static Handler b;
  private static m g = new m();
  private long c = 0L;
  private long d = 0L;
  private WeakReference<Context> e;
  private k f = new k();
  private boolean h = true;
  private boolean i = false;

  private m()
  {
    a.start();
    b = new Handler(a.getLooper());
  }

  public static m a()
  {
    return g;
  }

  private void a(Context paramContext)
  {
    if (paramContext == null)
    {
      b.a("stat", "clearLastSession(Context context):context=null");
      return;
    }
    a.a(false, paramContext, "__local_last_session.json", "{}", false);
  }

  private void a(boolean paramBoolean)
  {
    this.h = paramBoolean;
  }

  private void c(Context paramContext, long paramLong)
  {
    b.a("stat", "flush current session to last_session.json");
    new JSONObject();
    JSONObject localJSONObject = this.f.c();
    try
    {
      localJSONObject.put("e", paramLong);
      a.a(false, paramContext, "__local_last_session.json", localJSONObject.toString(), false);
      return;
    }
    catch (JSONException localJSONException)
    {
      b.a("stat", "StatSession.flushSession() failed");
    }
  }

  private boolean d()
  {
    return this.h;
  }

  public void a(Context paramContext, long paramLong)
  {
    b.a("stat", "post resume job");
    if (this.i)
      b.b(new Object[] { "stat", "遗漏StatService.onPause() || missing StatService.onPause()" });
    this.i = true;
    if (d())
    {
      a(false);
      b.post(new n(this));
    }
    p localp = new p(this, this.c, paramLong, paramContext);
    b.post(localp);
    this.e = new WeakReference(paramContext);
    this.d = paramLong;
  }

  public void b()
  {
    this.f.a(1 + this.f.d());
  }

  public void b(Context paramContext, long paramLong)
  {
    b.a("stat", "post pause job");
    if (!this.i)
    {
      b.b(new Object[] { "stat", "遗漏StatService.onResume() || missing StatService.onResume()" });
      return;
    }
    this.i = false;
    o localo = new o(this, paramLong, paramContext, this.d, (Context)this.e.get());
    b.post(localo);
    this.c = paramLong;
  }

  public long c()
  {
    return this.f.a();
  }
}

/* Location:           C:\Users\god\Desktop\liunianjishiben_V1.1_mumayi_3745b_dex2jar.jar
 * Qualified Name:     com.baidu.mobstat.m
 * JD-Core Version:    0.5.4
 */